<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../layui/css/layui.css"/>
	</head>
	<body style="padding: 30px 10px 10px 10px">
		<form class="layui-form" lay-filter="chanceDataFilter">
				<input type="hidden" name="chNo" />
				<div class="layui-form-item">
					<label class="layui-form-label">创建人</label>
					<div class="layui-input-inline" style="width: 30%;">
						<input type="text" name="chCreator"  lay-verify="required" autocomplete="off" placeholder="不可修改!" disabled class="layui-input layui-disabled" />
					</div>
					<label class="layui-form-label">创建时间</label>
					<div class="layui-input-inline" style="width: 30%;">
						<input type="text" name="chCreationdate" lay-verify="required|date" id='creationDate' autocomplete="off" placeholder="不可修改!" disabled class="layui-input layui-disabled" />
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">任务接收者</label>
					<div class="layui-input-inline" style="width: 30%;">
						<input type="text" value="未指派!" disabled class="layui-input layui-disabled" />
						
					</div>
					<label class="layui-form-label">指派时间</label>
					<div class="layui-input-inline" style="width: 30%;">					
						<input type="text" name="chRole" value="未分配 0000-00-00!" autocomplete="off" placeholder="不可修改!" disabled class="layui-input layui-disabled" />
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">客户名称<i style="color: red;"> * </i></label>
					<div class="layui-input-inline" style="width: 30%;">
						<input type="text" name="chName"  lay-verify="required" autocomplete="off" placeholder="请输入客户名称!" class="layui-input" />
						
						
					</div>
					<label class="layui-form-label">联系人<i style="color: red;"> * </i></label>
					<div class="layui-input-inline" style="width: 30%;">
						<input type="text" name="chContacts" lay-verify="required" lay-reqtext="不能为空!" autocomplete="off" placeholder="请输入联系人!" class="layui-input"/>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">客户电话<i style="color: red;"> * </i></label>
					<div class="layui-input-inline" style="width: 30%;">
						<input type="text" name="chPhone"  lay-verify="required|phone|number" autocomplete="off" placeholder="请输入联系电话!" class="layui-input" />
					</div>
				   <label class="layui-form-label">销售机会状态</label>
				     <div class="layui-input-inline" style="width: 30%;">
				     	<input type="text" value="未指派!" disabled class="layui-input layui-disabled" />
				     </div>
				</div>
				<div class='layui-form-item'>
					<label class="layui-form-label">概要描述</label>
					<div class="layui-input-inline" style="width: 60%;">
						<!-- <input type="text" name="chDescribed" autocomplete="off" placeholder="请输入概要描述!" class="layui-input"/> -->
						<textarea placeholder="请输入概要描述!" class="layui-textarea" name="chDescribed"></textarea>
					</div>
				</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button type="submit" class="layui-btn" lay-submit lay-filter="submitUpdateChance"> 提交</button>
					<button type="reset" class="layui-btn layui-btn-primary"> 重置</button>
				</div>
			</div>
			
		</form>
		<script src="../layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			layui.use(['form','jquery','layer'],function(){
				var form = layui.form   //定义form
				var $ = layui.jquery
				//将值赋给form  先要取得每一行的值  这里就用之前定义的全局变量row --> parent.row
				console.log(parent.row)  //  parent.row = {cusName: "重庆理工大学", cusUrl: "卢志强", cusRegion: "2222222222@qq.com"}
				form.val('chanceDataFilter',{  // 值应该是form的 lay-filter="chanceDataFilter" 值
					"chNo":parent.row.chNo,
					"chName":parent.row.chName,
					"chPhone":parent.row.chPhone,
					"chContacts":parent.row.chContacts,
					"chDescribed":parent.row.chDescribed,
					"chCreator":parent.row.chCreator,
					"chCreationdate":parent.row.chCreationdate,
					"chRole":parent.row.chRole,
					"chAssigindate":parent.row.chAssigindate,
					"chState":parent.row.chState,
				});
				//监听提交    lay-filter="submitUpdataChance"
				form.on('submit(submitUpdateChance)',function(backdata){ //backdata.field  
					// layer.msg("提交成功");
					$.ajax({
						async:true,
						url:'http://localhost:8080/chance/updateChance',  //后台地址
						type:'POST',  //提交方式 post get ....
						dataType:'JSON',//后台数据返回格式
						data:backdata.field,
						success:function(backjson){
							// 执行ajax提交成功后的处理代码  失败是另一种情况
							// debugger
							parent.table.reload('salesManage');//现在在子页面，要在父页面刷新  要把table定义为全局变量
							var index = parent.layer.getFrameIndex(window.name);
							parent.layer.close(index);
							
						},//回调函数 
					});
					return false;//阻止form提交刷新
				});
			})
		</script>
	</body>
</html>
